xend: Count CPUs rather than relying on a static
authorkfraser@localhost.localdomain <kfraser@localhost.localdomain>
Tue, 10 Jul 2007 09:13:16 +0000 (10:13 +0100)
committerkfraser@localhost.localdomain <kfraser@localhost.localdomain>
Tue, 10 Jul 2007 09:13:16 +0000 (10:13 +0100)
nodes/sockets/cores/threads relationship.
Signed-off-by: Alex Williamson <alex.williamson@hp.com>
tools/python/xen/xend/XendNode.py

index 60189fbe7b56c17f227da9481fea8bcbdbf1a98a..969c72dbc7a6f6a21b96f53ecac818a849041f79 100644 (file)
@@ -580,14 +580,17 @@ class XendNode:
             str='none\n'
         return str[:-1];
 
+    def count_cpus(self, pinfo):
+        count=0
+        node_to_cpu=pinfo['node_to_cpu']
+        for i in range(0, pinfo['nr_nodes']):
+            count+=len(node_to_cpu[i])
+        return count;
 
     def physinfo(self):
         info = self.xc.physinfo()
 
-        info['nr_cpus'] = (info['nr_nodes'] *
-                           info['sockets_per_node'] *
-                           info['cores_per_socket'] *
-                           info['threads_per_core'])
+        info['nr_cpus'] = self.count_cpus(info)
         info['cpu_mhz'] = info['cpu_khz'] / 1000
         
         # physinfo is in KiB, need it in MiB